import * as types from './mutations-types'
import {
	logout
} from '@/api/index.js'

const mtutaions = {
	// 设置搜索历史
	[types.SET_SEARCH_HISTORY](state, data) {
		state.searchHistory = data
	},
	//设置导航栏信息
	[types.SET_HEADER_INFO](state, data) {
		state.systeminfo = data.systeminfo
		state.headerBtnPosi = data.headerBtnPosi
	},
	//设置openid uid
	[types.SET_OUID](state, data) {
		state.oUid = data
	},
	//设置用户信息
	[types.SET_USER_INFO](state, data) {
		// if(!state.userInfo.wechat){
		// 	console.log(state.userInfo,data,1)
		// 	state.userInfo.wechat=''
		// }
		// if(!state.userInfo.zhifubaoAccount){
		// 	console.log(state.userInfo,data,2)
		// 	state.userInfo.zhifubaoAccount=''
		// }
		uni.setStorageSync('userInfo', Object.assign(state.userInfo, data))
		state.userInfo = Object.assign(state.userInfo, data)
	},
	//退出登录
	[types.LOG_OUT](state, data) {
		state.oUid = {}
		state.userInfo = {
			accessToken: '',
			invitationCode: '',
			zhifubaoAccount: '',
			alipayAccount: '',
			wechat: ''
		}
		uni.showLoading({
			mask: true
		})
		logout()
			.then(res => {
				that.$tips.toast(res.msg)
				uni.removeStorageSync('token')
				setTimeout(() => {
					uni.reLaunch({
						url: '/bundle/pages/login/login'
					})
				}, 2000)
			})
			.catch(err => {

			})
	},

	// 设置推广位id
	[types.SET_POSITIONIDS](state, data) {
		state.positionIds = data
	},

	// 显示粘贴板数据
	[types.SHOW_CLIPBOARD](state, data) {
		state.searchValue = data.searchValue
		state.dialogState = data.dialogState
		state.dialogType = data.dialogType
	},

	// 设置定位信息
	[types.SET_LOCATIONS](state, data) {
		console.log(data);
		state.location = data

	},
	// 设置陪玩项目
	[types.SET_PROJECT_TYPE](state, data) {
		// console.log(data);
		state.projectType = [...data]
	},

	[types.SET_MY_WALLINFO](state, data) {
		// console.log(data);
		state.myWallInfo = {
			...data
		}
	},
	[types.SET_MY_PROJECT_TYPE](state, data){
		state.myProjectType = [...data]
	},
	[types.SET_SELECT_CITY_TYPE](state, data){
		state.currentSelectCity = [...data]
	}

}

export default mtutaions